home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / CIncludes / UDialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-25  |  34.5 KB  |  838 lines  |  [TEXT/MPS ]

  1. /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
  2. /*UDialog.p*/
  3. /*Copyright © 1988-1990 by Apple Computer Inc.  All rights reserved.*/
  4. #ifndef  __UDialog__
  5. #define __UDialog__  0
  6. #endif
  7. #if  ! __UDialog__
  8. #define __UDialog__  1
  9.  
  10.         /* • Auto-Include the requirements for this unit's interface. */
  11. #ifndef  __UMacApp__
  12. #include "UMacApp.h"
  13. #endif
  14. #ifndef  __UTEView__
  15. #include "UTEView.h"
  16. #endif
  17.  
  18. const short kPreferColor        = true;                    /* argument to IIcon */
  19. const short kControlOn            = true;                    /* argument to ICheckBox and IRadio */
  20.  
  21.             /* Constants for TDialogView.Dismiss */
  22. const short kFlash                = true;                    /* Constants for TDialogView.Dismiss. */
  23. const short kDontFlash            = false;                /* Constants for TDialogView.Dismiss. */
  24.  
  25. const unsigned char kFrame                = (adnLineTop | adnLineLeft | adnLineBottom | adnLineRight);
  26.    /* Constant
  27.                 defining that a view be completely framed. */
  28.  
  29. const short kMaxTEWidth            = 0x2B0;                /* Maximum width for TEditText autoscroll */
  30.  
  31. const short phInvalidValue        = 300;                    /* Alert used when an invalid value is
  32.                                                          entered */
  33.  
  34. const short kInvalidValueReasons = 300;
  35.    /* String list used for invalid value alert */
  36. const short kErrorHandled        = - 1;
  37.    /* Don't post an alert, the user handled it */
  38. const short kValidValue            = 0;                    /* Not looked up in the string list. */
  39. const short kInvalidValue        = 1;
  40. const short kValueTooSmall        = 2;
  41. const short kValueTooLarge        = 3;
  42. const short kNonNumericCharacters = 4;
  43. const short kTooManyCharacters    = 5;
  44. const short kNoOfDefaultReasons = 5;
  45.  
  46. struct DialogViewTemplate {
  47.     ResType defaultItem;
  48.     ResType cancelItem;
  49. };
  50. typedef DialogViewTemplate *DialogViewTemplatePtr;
  51.  
  52. class TDialogView : public TView {
  53.   public:            /* Mimics normal toolbox dialogs providing
  54.                                                          behavior for handling default buttons,
  55.  
  56.                                                          param text, currently selected edit text
  57.                                                          and other behavior typically associated
  58.                                                          with dialogs. */
  59.     ResType fDefaultItem;                                /* The identifier of the default item */
  60.     ResType fCancelItem;
  61.        /* The identifier of item that cancels dialog
  62.                                                          */
  63.     TAssociation *fParamTxt;                            /* the list of TEntrys for replacement */
  64.     struct TEditText *fCurrentEditText;                    /* Currently selected edit text item */
  65.     struct TDialogTEView *fTEView;                        /* Used for editing in EditText views */
  66.     Boolean fDismissed;                                    /* Has the dialog been dismissed? */
  67.     ResType fDismisser;                                    /* ID of view that caused dismissal */
  68.  
  69.     virtual pascal void IDialogView(TDocument *itsDocument, TView *itsSuperView, VPoint *itsLocation
  70.        , VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, ResType 
  71.        itsDefItemID, ResType itsCancelItemID);
  72.                 /* Initialization method for TDialogView. */
  73.  
  74.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  75.                 /* For initializing a dialog view from a resource template. */
  76.  
  77.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  78.                 /* For writing a dialog view out to a resource. */
  79.  
  80.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  81.                 /* For writing a dialog view to a resource, works in conjunction with tbe
  82.                 previous method. */
  83.  
  84.     virtual pascal void Free(void);
  85.  
  86.        /* Frees fParamTxt then removes the sub view fTEView before calling inherited Free. */
  87.  
  88.     virtual pascal Boolean CanDismiss(ResType dismissing);
  89.                 /* Used to check whether the dialog view can be dismissed or not by checking if the
  90.                 view is enabled, then check if the currently selected edit text is valid. */
  91.  
  92.     virtual pascal void CantDeselect(struct TEditText *theEditText, long reason);
  93.  
  94.     virtual pascal void Close(void);
  95.                 /* Called to close a dialog view. */
  96.  
  97.     virtual pascal void DismissDialog(ResType dismisser);
  98.                 /* The method responsible for actually dismissing a dialog. */
  99.  
  100.     virtual pascal TCommand *DoCommandKey(short ch, EventInfo *info);
  101.                 /* Called when a keyDown event is received and the command key is down. */
  102.  
  103.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  104.                 /* This method handles all key presses other than a command key press, which is
  105.                 handled by the previous method. */
  106.  
  107.     virtual pascal void DoOpen(void);
  108.  
  109.         /* If when opening the dialog the current target is an edit text field of the dialog,
  110.  
  111.                 then select it. */
  112.  
  113.     virtual pascal Boolean DeselectCurrentEditText(void);
  114.                 /* Deselects the current edit text, this is called when tabbing between edit text
  115.                 fields. */
  116.  
  117.     virtual pascal void DoSelectEditText(struct TEditText *theEditText, Boolean selectChars);
  118.  
  119.         /* Selects theEditText, is selectChars then all the characters are selected otherwise
  120.                 the insertion point is merely placed at the start of the field. */
  121.  
  122.     virtual pascal void EachEditText(pascal void (*DoToEditText)(struct TEditText *theEditText, void
  123.         *DoToEditText_StaticLink), void *DoToEditText_StaticLink);
  124.                 /* Iterates over all the edit text items in the dialog calling DoToEditText for
  125.                 each item. */
  126.  
  127.     virtual pascal TView *GetDialogView(void);
  128.                 /* Returns a reference to the dialog view. */
  129.  
  130.     virtual pascal void Tab(Boolean tabBackward);
  131.                 /* Handles the tabbing between edit text fields. */
  132.  
  133.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  134.                 /* If the default or cancel key are pressed then dismisses the dialog, otherwise
  135.                 passes the message along the chain. If the hit was an edit text item then deselects
  136.                 the item. Otherwise if the hit is on some other control and it dismisses the dialog
  137.                 then dismiss it. */
  138.  
  139.     virtual pascal struct TDialogTEView *MakeTEView(void);
  140.                 /* Creates the floating TEView used with edit text fields. */
  141.  
  142.     virtual pascal void Open(void);
  143.                 /* Called to open a dialog. */
  144.  
  145.     virtual pascal void ParamTxt(StringPtr keyStr, StringPtr valueStr);
  146.                 /* Used to create paramTxt items for the dialog. Builds an association with keyStr
  147.                 and valueStr. All instance of keyStr in the dialog will be replaced with valueStr
  148.                 when the dialog is displayed. */
  149.  
  150.     virtual pascal ResType PoseModally(void);
  151.                 /* Displays the dialog in a modal fashion waiting for a response, which is returned
  152.                 as the IDType of the button hit that causes the dialog to be dismissed. */
  153.  
  154.     virtual pascal void ReplaceText(StringPtr theText);
  155.                 /* If there are any param text items in the theText passed to this method then they
  156.                 are replaced with the appropriate values. */
  157.  
  158.     virtual pascal void SelectEditText(ResType itsIdentifier, Boolean selectChars);
  159.  
  160.        /* If itsIdentifier can be found then the field is selected, selectChars if true means
  161.                 that all the text will be selected as opposed to the insertion point merely being
  162.                 placed in the field. */
  163.  
  164.     virtual pascal void SurveyEditText(struct TEditText **first, struct TEditText **last, struct 
  165.        TEditText **next, struct TEditText **previous);
  166.                 /* Iterates over the edit text items in the view finding the First, Last, Next and
  167.                 Previous items. */
  168.  
  169.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  170.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  171.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  172.                 fields. */
  173.  
  174. };
  175.  
  176. struct ButtonTemplate {
  177.     Str255 itsLabel;                                    /* Actually, variable length */
  178. };
  179. typedef ButtonTemplate *ButtonTemplatePtr;
  180.  
  181. class TButton : public TCtlMgr {
  182.   public:
  183.    /* Mimics a typical toolbox button as used in
  184.                                                          a dialog. */
  185.     virtual pascal void IButton(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  186.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel);
  187.                 /* Initializes the button setting the fDefChoice field to mButtonHit. */
  188.  
  189.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  190.                 /* Initialize the view from a resource template. */
  191.  
  192.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  193.                 /* Write this object out as a view resource. */
  194.  
  195.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  196.                 /* Set up the type and signature of this object and call WRes. */
  197.  
  198.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  199.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  200.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  201.                 fields. */
  202.  
  203. };
  204.  
  205. struct CheckBoxTemplate {
  206.     Boolean isOn;
  207.     Str255 itsLabel;                                    /* Actually, variable length */
  208. };
  209. typedef CheckBoxTemplate *CheckBoxTemplatePtr;
  210.  
  211. class TCheckBox : public TCtlMgr {
  212.   public:            /* Provides the functionality of a toolbox
  213.                                                          checkbox. */
  214.     virtual pascal void ICheckBox(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  215.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel, Boolean 
  216.        isTurnedOn);
  217.                 /* Initialize the checkbox setting fDefChoice to mCheckBoxHit. */
  218.  
  219.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  220.                 /*  Initialize the view from a resource template. */
  221.  
  222.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  223.                 /* Write this object out as a view resource. */
  224.  
  225.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  226.                 /* Set up the type and signature of this object and call WRes. */
  227.  
  228.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  229.                 /* If the hit is mCheckBoxHit then toggle the checkbox. */
  230.  
  231.     virtual pascal Boolean IsOn(void);
  232.                 /* Is the checkbox currently checked. */
  233.  
  234.     virtual pascal void SetState(Boolean state, Boolean redraw);
  235.                 /* Sets the state of the checkbox to state and if redraw is TRUE redraws it. */
  236.  
  237.     virtual pascal void Toggle(Boolean redraw);
  238.                 /* Toggles the state of the checkbox redraw it if redraw is TRUE. */
  239.  
  240.     virtual pascal void ToggleIf(Boolean matchState, Boolean redraw);
  241.                 /* Toggles the state of the checkbox if matchState is TRUE redrawing if redraw is
  242.                 TRUE. */
  243.  
  244.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  245.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  246.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  247.                 fields. */
  248.  
  249. };
  250.  
  251. struct RadioTemplate {
  252.     Boolean isOn;
  253.     Str255 itsLabel;                                    /* Actually, variable length */
  254. };
  255. typedef RadioTemplate *RadioTemplatePtr;
  256.  
  257. class TRadio : public TCtlMgr {
  258.   public:                /* Provides the functionality of a toolbox
  259.                                                          radio button. */
  260.     virtual pascal void IRadio(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  261.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel, Boolean 
  262.        isTurnedOn);
  263.                 /* Initalize the radio button procedurally. */
  264.  
  265.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  266.                 /*  Initialize the view from a resource template. */
  267.  
  268.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  269.                 /* Write the object out as a view resource. */
  270.  
  271.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  272.                 /* Set up the type and signature of this object and call WRes. */
  273.  
  274.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  275.                 /* If the hit is mRadioHit then toggle the radio button. */
  276.  
  277.     virtual pascal Boolean IsOn(void);
  278.                 /* Is the radio button currently on. */
  279.  
  280.     virtual pascal void SetState(Boolean state, Boolean redraw);
  281.                 /* Sets the state of the radio button to state, redrawing if redraw is TRUE. */
  282.  
  283.     virtual pascal void Toggle(Boolean redraw);
  284.                 /* Toggles the state of the radio button, redrawing if redraw is TRUE. */
  285.  
  286.     virtual pascal void ToggleIf(Boolean matchState, Boolean redraw);
  287.                 /* Only toggles the state of the radio button if matchState is TRUE, redrawing if
  288.                 redraw is TRUE. */
  289.  
  290.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  291.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  292.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  293.                 fields. */
  294.  
  295. };
  296.  
  297. struct ClusterTemplate {
  298.     Str255 itsLabel;                                    /* Actually, variable length */
  299. };
  300. typedef ClusterTemplate *ClusterTemplatePtr;
  301.  
  302. class TCluster : public TControl {
  303.   public:
  304.    /* Provides a mechanism whereby radio buttons
  305.                                                          can be grouped in clusters, such that when
  306.                                                          one of the buttons is selected the others
  307.                                                          are all deselected. Also can be utilized
  308.                                                          for providing labelled adornments around
  309.                                                          groups of dialog items. */
  310.     short fRsrcID;                                        /* resource ID of the cluster's label */
  311.     short fIndex;                                        /* currently selected item */
  312.     StringHandle fDataHandle;                            /* the cluster's label */
  313.  
  314.     virtual pascal void ICluster(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  315.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsIndex);
  316.                 /* Initialize the cluster procedurally. */
  317.  
  318.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  319.                 /*  Initialize the view template. */
  320.  
  321.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  322.                 /* Write the object out as a view resource. */
  323.  
  324.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  325.                 /* Set up the type and signature of this object and call WRes. */
  326.  
  327.     virtual pascal void Free(void);
  328.                 /* Release the label and call inherited free. */
  329.  
  330.     virtual pascal void Draw(Rect *area);
  331.                 /* Frame the cluster if there is a label, then draw the label. */
  332.  
  333.     virtual pascal void DoChoice(TView *origView, short itsChoice);
  334.                 /* Responsible for reset the radio buttons so that the last selected one is the only
  335.                 one selected. */
  336.  
  337.     virtual pascal void GetLabel(StringPtr theLabel);
  338.                 /* Returns in theLable the text in the clusters label. */
  339.  
  340.     virtual pascal void ReleaseLabel(void);
  341.  
  342.        /* Releases fDataHandle which is a string handle containing the text for the label. */
  343.  
  344.     virtual pascal ResType ReportCurrent(void);
  345.                 /* Returns the IDType of the currently selected item. */
  346.  
  347.     virtual pascal void SetLabel(StringPtr theLabel, Boolean redraw);
  348.                 /* Sets the clusters label to be theLabel, redrawing if redraw is TRUE. */
  349.  
  350.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  351.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  352.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  353.                 fields. */
  354. };
  355.  
  356. struct IconTemplate {
  357.     Boolean preferColor;
  358.     short rsrcID;
  359. };
  360. typedef IconTemplate *IconTemplatePtr;
  361.  
  362. class TIcon : public TControl {
  363.   public:                /* Provides an icon that can behave as a
  364.                                                          button. */
  365.     Boolean fPreferColor;
  366.     short fRsrcID;
  367.     Handle fDataHandle;
  368.  
  369.     virtual pascal void IIcon(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  370.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, Boolean preferColor)
  371.        ;
  372.                 /*  Initialize the view template. */
  373.  
  374.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  375.                 /* Initialize the view template. */
  376.  
  377.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  378.                 /* Write the object out as a view resource. */
  379.  
  380.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  381.                 /* Set up the type and signature of this object and call WRes. */
  382.  
  383.     virtual pascal void Free(void);
  384.                 /* Release the icon then call inherited Free. */
  385.  
  386.     virtual pascal void Draw(Rect *area);
  387.                 /* Resonsible for drawing the icon and any required adornments. */
  388.  
  389.     virtual pascal void ReleaseIcon(void);
  390.                 /* Releases the handle to the icon. */
  391.  
  392.     virtual pascal void SetIcon(Handle theIcon, Boolean redraw);
  393.                 /* Sets fDataHandle to theIcon, redrawing if redraw is TRUE. */
  394.  
  395.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  396.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  397.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  398.                 fields. */
  399. };
  400.  
  401. struct PatternTemplate {
  402.     Boolean preferColor;
  403.     short rsrcID;
  404. };
  405. typedef PatternTemplate *PatternTemplatePtr;
  406.  
  407. class TPattern : public TControl {
  408.   public:            /* Provides an object that can display a
  409.                                                          pattern and can also behave as a button if
  410.                                                          required. */
  411.     Boolean fPreferColor;
  412.     short fRsrcID;
  413.     Handle fDataHandle;
  414.  
  415.     virtual pascal void IPattern(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  416.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, Boolean preferColor)
  417.        ;
  418.                 /* Initialize the pattern procedurally. */
  419.  
  420.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  421.                 /* Initialize the view template. */
  422.  
  423.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  424.                 /* Write the object out as a view resource. */
  425.  
  426.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  427.                 /* Set up the type and signature of this object and call WRes. */
  428.  
  429.     virtual pascal void Free(void);
  430.                 /* Release the pattern then call inherited Free. */
  431.  
  432.     virtual pascal void Draw(Rect *area);
  433.                 /* Responsible for drawing the pattern and any required adornments. */
  434.  
  435.     virtual pascal void ReleasePattern(void);
  436.                 /* Releases the pattern by disposing fDataHandle. */
  437.  
  438.     virtual pascal void SetPattern(Handle thePattern, Boolean redraw);
  439.                 /* Sets fDataHandle to thePattern, redrawing if redraw is TRUE. */
  440.  
  441.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  442.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  443.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  444.                 fields. */
  445. };
  446.  
  447. struct PictureTemplate {
  448.     short rsrcID;
  449. };
  450. typedef PictureTemplate *PictureTemplatePtr;
  451.  
  452. class TPicture : public TControl {
  453.   public:
  454.    /* Provides an object that can display a PICT
  455.                                                          and if required behave like a button. */
  456.     short fRsrcID;
  457.     PicHandle fDataHandle;
  458.  
  459.     virtual pascal void IPicture(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  460.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID);
  461.                 /* Initialize the picture procedurally. */
  462.  
  463.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  464.                 /* Initialize the view from a resource template. */
  465.  
  466.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  467.                 /* Write the object out as a view resource. */
  468.  
  469.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  470.                 /* Set up the type and signature of this object and call WRes. */
  471.  
  472.     virtual pascal void Free(void);
  473.                 /* Release the picture then call inherited Free. */
  474.  
  475.     virtual pascal void Draw(Rect *area);
  476.                 /* Responsible for drawing the PICT and any required adornments. */
  477.  
  478.     virtual pascal void ReleasePicture(void);
  479.                 /* Releases the PICT by disposing of fDataHandle. */
  480.  
  481.     virtual pascal void SetPicture(PicHandle thePicture, Boolean redraw);
  482.                 /* Sets fDataHandle to thePicture, redrawing if redraw is TRUE. */
  483.  
  484.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  485.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  486.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  487.                 fields. */
  488. };
  489.  
  490. struct PopupTemplate {
  491.     short rsrcID;
  492.     short currentItem;
  493.     short itemOffset;
  494. };
  495. typedef PopupTemplate *PopupTemplatePtr;
  496.  
  497. class TPopup : public TControl {
  498.   public:                /* Provides a popup menu that can have a
  499.                                                          label associated with it. */
  500.     short fRsrcID;
  501.     short fMenuID;
  502.     MenuHandle fMenuHandle;
  503.     short fCurrentItem;
  504.     short fItemOffset;
  505.  
  506.     virtual pascal void IPopup(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  507.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsCurrentItem
  508.        , short itsItemOffset);
  509.                 /* Initialize the popup procedurally. */
  510.  
  511.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  512.                 /* Initialize the view template. */
  513.  
  514.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  515.                 /* Write the object out as a view resource. */
  516.  
  517.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  518.                 /* Set up the type and signature of this object and call WRes. */
  519.  
  520.     virtual pascal void Free(void);
  521.                 /* Release the popup then calls inherited Free. */
  522.  
  523.     virtual pascal void AdjustBotRight(void);
  524.                 /* Adjusts the width and height of the popup menu. */
  525.  
  526.     virtual pascal void CalcLabelRect(Rect *theRect);
  527.                 /* Calculates the size of the rect for the label. */
  528.  
  529.     virtual pascal void CalcMenuRect(Rect *theRect);
  530.                 /* Calculates the size of the rect for the menu. */
  531.  
  532.     virtual pascal TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *hysteresis);
  533.                 /* Responds to a mouse down on the popup menu by highlighting the label and then
  534.                 calling PopUpMenuSelect to handle the display of the menu and then sets the current
  535.                 item to the one selected. */
  536.  
  537.     virtual pascal void Draw(Rect *area);
  538.                 /* Calls DrawPopupBox and DrawLabel to handle the drawing of the popup box and the
  539.                 label. */
  540.  
  541.     virtual pascal void DrawLabel(Rect *area);
  542.                 /* Responsible for drawing the label. */
  543.  
  544.     virtual pascal void DrawPopupBox(Rect *area);
  545.                 /* Does the actual drawing of the popup box. */
  546.  
  547.     virtual pascal short GetCurrentItem(void);
  548.                 /* Returns the currently check marked item. */
  549.  
  550.     virtual pascal void GetItemText(short item, StringPtr theText);
  551.                 /* Gets the text for the currently selected item. */
  552.  
  553.     virtual pascal void ReleasePopup(void);
  554.                 /* Releases the popup by disposing of the menu handle. */
  555.  
  556.     virtual pascal void SetCurrentItem(short item, Boolean redraw);
  557.                 /* Sets the currently selected item, redrawing is required. */
  558.  
  559.     virtual pascal void SetPopup(MenuHandle theMenu, short theRsrcID, short currentItem, Boolean 
  560.        redraw);
  561.                 /* Sets the fields of the popup to contain theMenu, with currentItem selected,
  562.  
  563.                 redrawing if required. */
  564.  
  565.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  566.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  567.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  568.                 fields. */
  569. };
  570.  
  571. struct StaticTextTemplate {
  572.     short just;
  573.     Str255 data;                                        /* Actually, variable length */
  574. };
  575. typedef StaticTextTemplate *StaticTextTemplatePtr;
  576.  
  577. class TStaticText : public TControl {
  578.   public:            /* Provides an object that represents a
  579.                                                          toolbox static text item. */
  580.     short fRsrcID;                                        /* ID of the string list that the string is
  581.                                                          in. */
  582.     short fIndex;
  583.        /* Index number for the string from the above
  584.                                                          list. */
  585.     StringHandle fDataHandle;                            /* A handle to the actual string. */
  586.     short fJust;
  587.        /* Jusitification of the text in the field. */
  588.     Boolean fAutoWrap;
  589.        /* TRUE to word wrap lines at the view boundary
  590.                                                         otherwise lines wrap at Carriage return. */
  591.  
  592.     virtual pascal void IStaticText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, 
  593.        SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsIndex);
  594.                 /* Initialize the static text field procedurally. */
  595.  
  596.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  597.                 /* Initialize the view template. */
  598.  
  599.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  600.                 /* Write the object out as a view resource. */
  601.  
  602.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  603.                 /* Set up the type and signature of this object and call WRes. */
  604.  
  605.     virtual pascal void Free(void);
  606.                 /* Releases the text and then calls inherited Free. */
  607.  
  608.     virtual pascal void DoSubstitution(StringPtr theText);
  609.                 /* Calls ReplaceText so that any paramTxt items can be handled if needed. */
  610.  
  611.     virtual pascal void Draw(Rect *area);
  612.                 /* Draws the text by calling ImageText. */
  613.  
  614.     virtual pascal void GetText(StringPtr theText);
  615.  
  616.        /* If fDataHandle not NIL then returns the text, otherwise returns the null string. */
  617.  
  618.     virtual pascal void ImageText(Ptr text, long length, Rect *box, short just);
  619.                 /* Draws the text using the toolbox routine TextBox. */
  620.  
  621.     virtual pascal void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
  622.                 /* Changes auto-wrapping behavior, redrawing if requested */
  623.  
  624.     virtual pascal void ReleaseText(void);
  625.                 /* Releases the text by disposing of fDataHandle. */
  626.  
  627.     virtual pascal void SetJustification(short theJust, Boolean redraw);
  628.                 /* Sets the justification of the text to theJust, redrawing if required. */
  629.  
  630.     virtual pascal void SetText(StringPtr theText, Boolean redraw);
  631.                 /* Sets the text to theText, redrawing if required. */
  632.  
  633.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  634.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  635.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  636.                 fields. */
  637. };
  638.  
  639. struct EditTextTemplate {
  640.     short maxChars;
  641.     ControlCharSet controlChars;
  642. };
  643. typedef EditTextTemplate *EditTextTemplatePtr;
  644.  
  645. class TEditText : public TStaticText {
  646.   public:        /* Implements an edit text field. */
  647.     short fMaxChars;
  648.     struct TDialogTEView *fTEView;
  649.     ControlCharSet fControlChars;                        /* Control chars accepted in text */
  650.  
  651.     virtual pascal void IEditText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, short 
  652.        itsMaxChars);
  653.                 /* Initialize the edit text item procedurally. */
  654.  
  655.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  656.                 /* Initialize the view from a resource template. */
  657.  
  658.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  659.                 /* Write the object out as a view resource. */
  660.  
  661.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  662.                 /* Set up the type and signature of this object and call WRes. */
  663.  
  664.     virtual pascal void Free(void);
  665.  
  666.         /* Un-installs the floating TEView, sets fTEView to NIL then calls inherited Free. */
  667.  
  668.     virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis, 
  669.        TCommand **theCommand);
  670.                 /* Gets the floating TE installed if necessary and forwards the call to it. */
  671.  
  672.     virtual pascal void DoSubstitution(StringPtr theText);
  673.                 /* Default is to do nothing. */
  674.  
  675.     virtual pascal void Draw(Rect *area);
  676.  
  677.        /* If TEView not NIL then calls TEView.Draw before performing any required adornments,
  678.  
  679.                 else calls inherited Draw. */
  680.  
  681.     virtual pascal void GetText(StringPtr theText);
  682.                 /* If TEView not NIL then returns the extracted text, otherwise calls inherited
  683.                 GetText. */
  684.  
  685.     virtual pascal void ImageText(Ptr text, long length, Rect *box, short just);
  686.                 /* Sets up the text to the parameters passed. Text is drawn in a'box' , the text is
  687.                 'length' long. */
  688.  
  689.     virtual pascal void InstallSelection(Boolean wasActive, Boolean beActive);
  690.                 /* If TEView not NIL then calls TEView.InstallSelection. */
  691.  
  692.     virtual pascal void RestartEdit(StringPtr restartText);
  693.                 /* This method resets the text of the view, as well as selecting the text. We go to
  694.                 some extra trouble to ensure that this method doesn't do any drawing, defering to
  695.                 window update time. The reasoning is that this method usually gets called right
  696.                 after displaying an alert. The alert may have obscured this view, thus including it
  697.                 in the window's update region. If we drew in this method we would get flashing as
  698.                 this view would get redraw at update time. Unfortunately TextEdit isn't very
  699.                 cooperative so we set the clipping to an empty rect to ensure that TEActivate's
  700.                 drawing isn't seen. */
  701.  
  702.     virtual pascal void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
  703.                 /* Changes auto-wrapping behavior, redrawing if requested.  Forwards into
  704.                 the floating TE if necessary. */
  705.  
  706.     virtual pascal void SetJustification(short theJust, Boolean redraw);
  707.                 /* Sets the justification of the text to theJust, redrawing is required. */
  708.  
  709.     virtual pascal void SetSelection(short selStart, short selEnd, Boolean redraw);
  710.                 /* Sets the selection in the field starting at selStart and ending at selEnd,
  711.  
  712.                 redrawing if required. */
  713.  
  714.     virtual pascal void SetText(StringPtr theText, Boolean redraw);
  715.                 /* Sets the displayed text to theText, redrawing if required. */
  716.  
  717.     virtual pascal void StartEdit(Boolean selectChars, struct TDialogTEView *theTEView);
  718.                 /* Install the selection, revealing the selection if required. */
  719.  
  720.     virtual pascal void StopEdit(void);
  721.                 /* Extracts the string from the TEView, then clears out the TEView before calling
  722.                 SELF.SetText. */
  723.  
  724.     virtual pascal long Validate(void);
  725.                 /* By default just returns TRUE. */
  726.  
  727.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  728.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  729.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  730.                 fields. */
  731. };
  732.  
  733. struct NumberTextTemplate {
  734.     long value;
  735.     long minimum;
  736.     long maximum;
  737. };
  738. typedef NumberTextTemplate *NumberTextTemplatePtr;
  739.  
  740. class TNumberText : public TEditText {
  741.   public:
  742.    /* This subclass of TEditText that allows the
  743.                                                          handling of integer numbers. Range
  744.                                                          checking will be performed on the numbers
  745.                                                          entered to see if they are in the range
  746.                                                          fMinimum to fMaximum. */
  747.     long fMinimum;
  748.     long fMaximum;
  749.  
  750.     virtual pascal void INumberText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, long 
  751.        itsValue, long itsMinimum, long itsMaximum);
  752.                 /* Initialize the number text item procedurally. */
  753.  
  754.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  755.                 /* Initialize the view template. */
  756.  
  757.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  758.                 /* Write the object out as a view resource. */
  759.  
  760.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  761.                 /* Set up the type and signature of this object and call WRes. */
  762.  
  763.     virtual pascal long GetValue(void);
  764.                 /* Returns the current value by getting the string and converting it to a number. */
  765.  
  766.     virtual pascal void SetValue(long newValue, Boolean redraw);
  767.                 /* Sets the current value by converting the number to a string and then calling
  768.                 SetText. */
  769.  
  770.     virtual pascal long Validate(void);
  771.  
  772.         /* Does a range check on the number and if it is out of range returns the appropriate
  773.                 error code. */
  774.  
  775.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  776.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  777.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  778.                 fields. */
  779. };
  780.  
  781. class TDialogTEView : public TTEView {
  782.   public:        /* Provides a floating TEView that is placed
  783.                                                          over edit & number text fields when
  784.                                                          entering text. */
  785.     TEditText *fEditText;                                /* The edit text field to which the floating
  786.                                                          TEView is currently tied. */
  787.  
  788.     TScroller *fScroller;
  789.        /* The scroller that I am in for mouseability. */
  790.  
  791.     virtual pascal void IDialogTEView(TDocument *itsDocument, TView *itsSuperView, VPoint *
  792.        itsLocation, VPoint *itsSize, SizeDeterminer itsHDeterminer, SizeDeterminer itsVDeterminer, 
  793.        Rect *itsInset, TextStyle *itsTextStyle, short itsJustification, Boolean itsStyleType, Boolean
  794.         itsAutoWrap);
  795.                 /* For Initialization of procedurally created TEView. */
  796.  
  797.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  798.                 /* Initialize a TTEView via a 'view' resource. */
  799.  
  800.     virtual pascal void Free(void);
  801.                 /* Free associated components and then free self. */
  802.  
  803.     virtual pascal void InstallEditText(TEditText *theEditText, Boolean selectChars);
  804.                 /* Installs the EditText adding SELF as a subview to EditText, then gets the text
  805.                 from the EditText item and installs it in SELF. */
  806.  
  807.     virtual pascal void ComputeSize(VPoint *newSize);
  808.                 /* accounts for case in which horizontal determiner is sizeVariable should be added
  809.                 to TTEView !!! */
  810.  
  811.     virtual pascal void InstallSelection(Boolean wasActive, Boolean beActive);
  812.  
  813.         /* If deactivating then invalidate rect before calling inherited InstallSelection. */
  814.  
  815.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  816.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  817.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  818.                 fields. */
  819.  
  820.     virtual pascal struct TScroller *MakeScroller(void);
  821.                 /*  Creates the floating scroller that goes with the TE. . */
  822.  
  823.  
  824. };
  825.  
  826. extern pascal void InitUDialog(void);
  827.         /* This routine must be called if UDialog is used so that all the necessary initializati
  828.            on can
  829.         be performed. Sets the global flag 'gUDialogInitialized' after the initalization is
  830.         performed. */
  831.  
  832. extern pascal void GetMenuColors(Rect *popupRect, short menuID, short itemNum, RGBColor *fColor,
  833.         RGBColor *bColor);
  834.         /*  */
  835.  
  836. #endif
  837.  
  838.